import java.util.Arrays;

class MyStack2<E>{
    public Object[] elem;
    public int useSize;

    public MyStack2(){
        this.elem=new Object[10];
    }
    public boolean ifFull(){
        return useSize==elem.length;
    }
    public void push(E val){
        if(ifFull()){
            elem= Arrays.copyOf(elem,elem.length*2);
        }
        elem[useSize]=val;
        useSize++;

    }
    public E pop(){
        if(empty()){
            return null;
        }
        E oidVal=(E) elem[useSize-1];
        useSize--;
        return oidVal;

    }
    public boolean empty(){
        return useSize==0;
    }
    public E peek(){
        if(empty()){
            return null;
        }
        return (E) elem[useSize-1];
    }
}
public class Text3 {
    public static void main(String[] args) {
        MyStack2<Integer> myStack=new MyStack2<>();
        myStack.push(10);
    }
}
